package com.atguigu.boot.controller;
import com.atguigu.boot.bean.Dog;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DogController2 implements ApplicationContextAware {
    private ApplicationContext applicationContext;

    @GetMapping(value = "/dog_2")
    public Dog getDog() {
        Dog dog = applicationContext.getBean(Dog.class);
        dog.setDogNickName("黄黄-2");
        dog.setDogAge(3);
        return dog;
    }
    @GetMapping(value = "/dog_3")
    public Dog getDog_1() {
        Dog dog = new Dog();
        dog.setDogNickName("黄黄-3");
        dog.setDogAge(3);
        return dog;
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
